<tagLib name="html" />
<include file="__THEME__/header" />
<link href="../Public/css/space.css" rel="stylesheet" type="text/css" />
<div class="contents lbg B">
  <!--左边信息 begin-->
  <include file="../Public/home_left" />
  <!--中间信息 begin--->
  <div class="contents_min w787">
    <h3 class="tit_h3">{:L('nav_baseinfo')}</h3>
    <p class="f12 cl03 mb10 pl5"><img class="alM pr5" src="../Public/images/title_icon_17.gif" />{:L('base_infomation')}</p>
    <div class="list_cate_nav">
      <div class="tab"> <span class="R f12 pt10 pr10"><a href="{:U('space/View/index',array('uid'=>$mid))}?preview">{:L('base_preview')}</a></span>
        <ul>
          <volist id="vo" name="topmenu">
            <php>$class=($type==$key)?'class="sam_status on"':''</php>
            <li {$class}><span><a href="{$vo.url}" >{$vo.info}</a></span>{:$_GET['act']}</li>
          </volist>
        </ul>
      </div>
    </div>
    <div class="C"></div>
    <div class="base_input">
      <form action="" method="post" id="baseinfo_form" autocomplete="off" onsubmit="return checkform()">
        <table width="100%" border="0" align="left" cellpadding="0" cellspacing="0">
          <volist id="vo" name="list">
            <php>if($isHrbi){</php>
            <tr height="35">
              <td align="right" width="10%">{$vo.info}：</td>
              <td align="left" width="75%"><span class="cl03" id="have_edit_{$vo.field}">{$vo.value}</span>
                <input class="in_put" style="width:200px;"  name="data[{$vo.field}]" type="hidden"  value="{$vo.value}" /></td>
              <td align="left"><php>if($vo['need']){</php>
                <input type="checkbox" name="index[]" checked disabled value="{$vo.field}" />
                {:L('show_space')}
                <php>}else{</php>
                <input type="checkbox" name="index[]" <php>if(in_array($vo['field'],$space)){</php>checked<php>}</php>  value="{$vo.field}" />{:L('show_space')}
                <php>}</php></td>
            </tr>
            <php>}else{</php>
            <tr height="35">
              <td align="right" >{$vo.info}：</td>
              <td align="left" width="60%"><switch name="vo['field']">
                  <case value="cardId|shortname"> {$vo.value}
                    <input type="hidden" name="data[{$vo.field}]" class="in_put" value="{$vo.value}" style="width:200px;" />
                  </case>
                  <case value="usersex">
                    <php>$options = array('GG'=>'GG','MM'=>'MM');$usersex=$vo['value']</php>
                    <html:select name="data[usersex]" options='{options}' selected='{usersex}' />
                  </case>
                  <default/>
                  <input type="text" name="data[{$vo.field}]" class="in_put" style="width:200px;" value="{$vo.value|htmlspecialchars}" maxlength="40" />
                </switch></td>
              <td align="left"><php>if($vo['need']){</php>
                <input type="checkbox" name="index[]" checked disabled value="{$vo.field}" />
                {:L('show_space')}
                <php>}else{</php>
                <input type="checkbox" name="index[]" 
                <php>if(in_array($vo['field'],$space)){</php>
                checked
                <php>}</php>
                value="{$vo.field}" />{:L('show_space')}
                <php>}</php></td>
            </tr>
            <php>}</php>
          </volist>
          </tr>
        </table>

      <div class="C"></div>
      <div class="mt10" style="padding-left:40px;">
      	<input class="btn_sea mr5" name="" type="submit" value="{:L('info_save')}" />           
              <php>if($isHrbi){</php>
              <input class="btn_sea" name="" id="updatahandle"  type="button" onclick="getHrbiInfo('{$cardId}')" value="{:L('update_info')}" />
              <php>}</php>
      </div>
	 </form>
    </div>
  </div>
  <!--中间信息 begin--->
  <div class="C"></div>
</div>
<script>
	function checkform(){
		var username   = $.trim($("#baseinfo_form [name='data[username]']").val());
		var department = $.trim($("#baseinfo_form [name='data[department]']").val());
		var englishname = $.trim($("#baseinfo_form [name='data[englishname]']").val());
		if(!username){
			$.tbox.no('{:L("validate_name_no_empty")}','{:L("do_failure")}');
			$("#baseinfo_form [name='data[username]']").focus();
			return false;
		}
		if(username.length >=16){
			$.tbox.no('{:L("validate_name_too_long")}','{:L("do_failure")}');
			$("#baseinfo_form [name='data[username]']").focus();
			return false;
		}		
		if(!department){
			$.tbox.no('{:L("validate_department_no_empty")}','{:L("do_failure")}');
			$("#baseinfo_form [name='data[department]']").focus();
			return false;
		}
		if(!englishname){
			$.tbox.no('{:L("validate_englishname_no_empty")}','{:L("do_failure")}');
			$("#baseinfo_form [name='data[englishname]']").focus();
			return false;
		}
		return true;
	}
</script>

<php>if($isHrbi){</php>
<script>
	//提取用户最新的HRBI资料
	function getHrbiInfo(cardId){
		var ob = '';
		var oe = '';
		var newn = 0;
		$('#updatahandle').val('{:L("data_updating")}');
		$.getJSON('__URL__&act=getHrbiInfo',{cardId:cardId},function(data){
			$.each(data,function(i,item){
				ob = $("#baseinfo_form [name='data["+item.field+"]']");			
				if(ob.val()!=item.value){
					ob.removeAttr('readonly');
					ob.val(item.value);
					$("#have_edit_"+item.field).css('border','1px solid red');
					$("#have_edit_"+item.field).html(item.value);
					newn++;
				}
			});
			if(newn==0){
				$('#updatahandle').val('{:L("data_is_newest")}');
			}
		})
	}
	</script>
<php>}</php>

<include file="__THEME__/footer" />